function [f, ma] = computey(theta2,sj,v,x2,p,QI,ind_market,A1,deltaold,sales_tax) 

delta=zeros(size(ind_market));
marg=zeros(size(ind_market));

for i=1:max(ind_market)
    temp=find(ind_market==i);
    delta(temp)=contraction(theta2,sj(temp),v,x2(temp,:),p(temp,:) ...
        ,QI(temp,:),ind_market(temp,:),deltaold(temp,:));% run "contraction" script
    marg(temp)=(p(temp,:)./(1+sales_tax(temp,:)))-markup(theta2,v,x2(temp,:),p(temp,:),delta(temp),ind_market(temp,:),A1(temp,temp),...
        sj(temp),QI(temp,:)); % marginal cost = price - markup 
end

f=delta; 
ma=log(marg);
%ma=marg;
